package com.xiahui.day11.Test7;

public class TestStudent {
    public static void main(String[] args) {
        Student stu1 = new Student();
        stu1.setName("赵四");
        stu1.setAge(20);

        Address address = new Address();
        address.setProvince("广东省");
        address.setCity("深圳市");
        address.setArea("宝安区");
        address.setStreet("航城街道");
        address.setZipCode("895645");

        stu1.setAddress(address);
        System.out.println("------------------------------------------------------------");
        // 关于空指针异常
        // 只要使用指向为null的引用 调用任何的属性或者方法 就会产生空指针异常
        Hobby [] hobbies = new Hobby[3];

        hobbies[0] = new Hobby();
        hobbies[0].setHobbyType("电子竞技");
        hobbies[0].setHobbyName("LOL");

        hobbies[1] = new Hobby();
        hobbies[1].setHobbyType("文艺类");
        hobbies[1].setHobbyName("尬舞");

        hobbies[2] = new Hobby();
        hobbies[2].setHobbyType("体育类");
        hobbies[2].setHobbyName("唱跳RAP 篮球");

        for (int i = 0; i <hobbies.length; i++) {
            System.out.println(hobbies[i]);
        }

        stu1.setHobbies(hobbies);






        System.out.println("------------------------------------------------------------");

        System.out.println(stu1.getName());
        System.out.println(stu1.getAge());
        System.out.println(stu1.getAddress());
        System.out.println(stu1.getAddress().getProvince());
        System.out.println(stu1.getAddress().getCity());
        System.out.println(stu1.getAddress().getArea());
        System.out.println(stu1.getAddress().getStreet());
        System.out.println(stu1.getAddress().getZipCode());

        System.out.println("------------------------------------------------------------");


        Hobby[] hobbies1 = stu1.getHobbies();

        for (int i = 0; i<hobbies1.length; i++) {
            System.out.println(hobbies1[i]);
            System.out.println(hobbies1[i].getHobbyType());
            System.out.println(hobbies1[i].getHobbyName());
        }

        System.out.println("------------------------------------------------------------");


        System.out.println(stu1);



    }
}


